//
//  HomeTableViewCell.swift
//  FirstSwiftProduct
//
//  Created by 知合金服-Mini on 2017/10/27.
//  Copyright © 2017年 范泽华. All rights reserved.
//

import UIKit

class HomeTableViewCell: UITableViewCell {

    @IBOutlet weak var biaodiName: UILabel!
   
    @IBOutlet weak var biaodiNumber: UILabel!
    
    @IBOutlet weak var yearShouyilv: UILabel!
    
    @IBOutlet weak var time: UILabel!
    
    @IBOutlet weak var totalMoney: UILabel!
    
    @IBOutlet weak var touziButton: UIButton!
    
    @IBOutlet weak var progressTopView: UIView!
    @IBOutlet weak var progressView: UIView!
    @IBOutlet weak var progressLabel: UILabel!
    override func awakeFromNib() {
        super.awakeFromNib()
        
        // Initialization code
        touziButton.layer.cornerRadius = 3 * scaleWidth
        touziButton.layer.masksToBounds = true
        
        
        progressView.layer.cornerRadius = 3 * scaleWidth
        progressView.layer.masksToBounds = true
        
        progressTopView.layer.cornerRadius = 3 * scaleWidth
        progressTopView.layer.masksToBounds = true
        let stringLv = "11.00%"
        
        let attr = NSMutableAttributedString.init(string: stringLv)
        attr.addAttributes([NSFontAttributeName:UIFont.systemFont(ofSize: 25*scaleWidth)], range: NSMakeRange(0, stringLv.characters.count - 1))
        attr.addAttributes([NSFontAttributeName:UIFont.systemFont(ofSize: 12.5*scaleWidth)], range: NSMakeRange(stringLv.characters.count - 1, 1))
        
        yearShouyilv.attributedText = attr
        
       
        commit()
        
    }
    
    open func commit() -> Void {
        
        let width = progressView.width
        UIView.animate(withDuration: 1) {
            let arc:CGFloat = CGFloat(arc4random_uniform(256)) / 256
            
//            print(arc)
            let number:CGFloat = 60
//            print(number,width)
            self.progressTopView.width =  width * arc
            //            self.progressTopView.frame = CGRect(x: 0, y: 0, width: width * 0.5, height: 7)
            self.progressLabel.text = String(format: "%.1f",number).appending("%")
            
        }
    }
    
    @IBAction func touziAction(_ sender: UIButton) {
        
        print("我点击了投资")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
